﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="MvcContrib.FluentHtml.ModelViewPage<IEnumerable<Dgg.Anug.Cqrs.Core.Presentation.Models.Admin.AppVersion>>" %>
<%@ Import Namespace="MvcContrib.UI.DataList"%>
<%@ Import Namespace="Dgg.Anug.Cqrs.Core.Presentation.Controllers" %>

<asp:Content ContentPlaceHolderID="TitleContent" runat="server">
	All Versions
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContent" runat="server">

	<h2>All Versions</h2>
	<% Html.DataList(Model).CellTemplate(item =>
    {%>
		<div class="background withContext <%: item.AssignedTo != null %>" id="<%: item.Id %>">
			<b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b>
				<span class="padded"><%= item.Name %></span>
			<b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b>
		</div>
     <%})
	.EmptyDateSourceTemplate(()=>{%>
		No Versions
	<%}).Render(); %>

	<p><%= Html.ActionLink<AppVersionController>(c => c.Create(), "Create") %></p>

</asp:Content>
<asp:Content ContentPlaceHolderID="ScriptContent" runat="server">
		<script type="text/javascript">
			$(function () {
				var actions = new MenuActionsForModelRelatedToVersion(
					'<%=Guid.Empty %>',
					'<%= Html.ActionLink<AppVersionController>(c => c.Rename(Guid.Empty), "r") %>',
					'<%= Html.ActionLink<AppVersionController>(c => c.Assign(Guid.Empty), "a") %>',
					'<%= Html.BuildUrlFromExpression<AppVersionController>(c => c.UnAssign(Guid.Empty)) %>',
					'<%= Html.BuildUrlFromExpression<AppVersionController>(c => c.Delete(Guid.Empty)) %>');

				$('.withContext').contextMenu({ menu: 'versionMenu' },
					function (action, el, pos) {
						actions.performAction(action, $(el).attr('id').toString());
					},
					function (element, menu) { actions.trimActions(element, menu); });
			});
		</script>
		<%Html.RenderPartial("versionMenu"); %>
</asp:Content>
